<?php

class Application_Model_Tasks extends Common_Model {

    public $tableName = 'Tasks';

    const S_OK = 1;
    const S_NONE = 0;
    const S_WTOKU = 2;

    public static $status = array(
        self::S_NONE => 'w toku',
        self::S_OK => 'zrobione',
        self::S_WTOKU => 'w toku',
    );

    public function checkIfExist($object, $class, $status = self::S_NONE) {
        return $this->table->fetchRow('objectId=' . $object . ' and class=\'' . $class . '\''.( is_array($status) ? ' and status in(' . implode(',',$status).')': ' and status='.$status) );
    }
    
    public function getByObjectId($objectId, $class = null, $status = null) {
        return $this->table->fetchRow('objectId=' . $objectId . ''.($class!=null?' and class=\'' . $class . '\'':'').''.(is_array($status) ? ' and status in(' . implode(',',$status).')': ($status!=null ? ' and status='.$status:'') ) );
    }

}

